DB2 SQL Practice Online
DB2 SQL Practice Online
Run real SQL in your browser • Sample EMP/DEPT tables • No signup, free
Loading database, please wait...
Most common DB2 queries — click any to load and run it
Basics
Simple SELECT, column lists, sorting and single-condition filters.
Filtering rows
BETWEEN, LIKE and IN — the three most-used WHERE patterns.
Joins
Combine EMP and DEPT; LEFT JOIN keeps rows that have no match.
Aggregation & subqueries
GROUP BY, HAVING and subqueries — the interview favorites.
Tip: press Ctrl+Enter (Cmd+Enter on Mac) to run. INSERT, UPDATE and DELETE work too — Reset restores the sample data.
Loading...
View table schemas
DEPT(DEPTNO INTEGER PRIMARY KEY, DNAME VARCHAR(20), LOC VARCHAR(20)) — 4 rows
EMP(EMPNO INTEGER PRIMARY KEY, ENAME VARCHAR(20), JOB VARCHAR(20), SAL INTEGER, DEPTNO INTEGER) — 10 rows
How this works: your SQL runs on SQLite inside your browser (via sql.js / WebAssembly) — there is no backend and nothing is sent anywhere.
Standard SQL —
SELECT, JOIN, GROUP BY, subqueries — behaves the same in Db2, so this is genuine practice.
A few Db2-only differences to remember:
- Db2 limits rows with
FETCH FIRST n ROWS ONLY; SQLite usesLIMIT n. - Db2 has special registers like
CURRENT DATEandCURRENT TIMESTAMPthat SQLite lacks. - Some scalar functions and date arithmetic differ between the two — check the Db2 docs when in doubt.
